package gameHandling;

import gameObject.Hero;
import gameObject.item.ItemSwordBasic;

import javax.microedition.lcdui.Graphics;

import main.PlayingCanvas;

public class PlaceHeroHandling extends PlaceHandling{
	Hero hero;
	public PlaceHeroHandling(Hero hero) {
		this.hero = hero;
		colIndex = hero.getColIndex();
		rowIndex = hero.getRowIndex();
		PlayingCanvas.getGame().objectMap[colIndex][rowIndex]=0;
	}
	public PlaceHeroHandling() {
		
	}
	public boolean pointerTaped(int x,int y)
	{
		int i = x/30;
		int j = y/30;
		if(PlayingCanvas.getGame().objectMap[i][j]==0 && j>0)
		{
			colIndex = i;
			rowIndex = j;
			if(hero == null)
			{
				hero = new Hero();
				hero.setArm(new ItemSwordBasic());
				int cost = PlayingCanvas.getGame().getHeroCost();
				if(PlayingCanvas.getGame().money<cost){
					PlayingCanvas.getInstance().setMessage("Not enough money");
				}else{
					PlayingCanvas.getInstance().setMessage("-"+cost+"G");
					PlayingCanvas.getGame().money-=cost;
					PlayingCanvas.getGame().AddHero(hero,i,j);
				}
			}
			else
			{
				hero.setMapIndex(i, j);
				PlayingCanvas.getGame().objectMap[i][j]=1;
			}
			PlayingCanvas.getInstance().doneHandling();
		}
		return true;
	}
	public void paint(Graphics g){
		super.paint(g);
		
		if(rowIndex == -1)
		{
			return;
		}
	}
	public void execute(){		
	}
}
